﻿using LJ.Host.Abstractions.Pack;

namespace LJ.Host.Web.Extensions;

public static class WebApplicationExtensions
{
    public static WebApplication UseLJ(this WebApplication webApplication)
    {
       
        var packProvider = new AspNetCorePackProvider(webApplication);

        var packManager = webApplication.Services.GetRequiredService<IPackManager>();


        packProvider.Logger.LogInformation("---------------------");
        packProvider.Logger.LogInformation("Load LJ");

        foreach (var pack in packManager.GetPacks())
        {
             pack.Use(packProvider);


            packProvider.Logger.LogInformation("Load Pack:{name}", pack.GetType().Name);
        }
        packProvider.Logger.LogInformation("Load Pack Ok");
        packProvider.Logger.LogInformation("---------------------");

        return webApplication;
    }
}
